<div class="content-section introduction">
    <div class="feature-intro">
        <h1>ConfirmPopup</h1>
        <p>ConfirmPopup displays a confirmation overlay displayed relatively to its target.</p>
    </div>
    <app-demoActions github="confirmpopup" stackblitz="confirmpopup-demo"></app-demoActions>
</div>

<div class="content-section implementation">
    <p-toast></p-toast>

    <div class="card">
        <p-button (click)="confirm($event)" icon="pi pi-check" label="Confirm"></p-button>
        <p-confirmPopup></p-confirmPopup>
    </div>
</div>

<div class="content-section documentation">
    <p-tabView>
        <p-tabPanel header="Documentation">
            <h5>Import</h5>
<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
import &#123;ConfirmPopupModule&#125; from 'primeng/confirmpopup';
import &#123;ConfirmationService&#125; from 'primeng/api';
</app-code>

            <h5>Getting Started</h5>
            <p>ConfirmPopup is defined using p-confirmPopup tag and an instance of ConfirmationService is required to display it by
                calling confirm method.</p>

<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-confirmPopup&gt;&lt;/p-confirmPopup&gt;

&lt;button (click)="confirm($event)" pButton icon="pi pi-check" label="Confirm"&gt;&lt;/button&gt;
</app-code>

<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class ConfirmPopupDemo &#123;

    constructor(private confirmationService: ConfirmationService) &#123;&#125;

    confirm(event: Event) &#123;
        this.confirmationService.confirm(&#123;
            target: event.target,
            message: 'Are you sure that you want to proceed?',
            icon: 'pi pi-exclamation-triangle',
            accept: () => &#123;
                //confirm action
            &#125;,
            reject: () => &#123;
                //reject action
            &#125;
        &#125;);
    &#125;
&#125;
</app-code>

            <p>Confirm method takes a confirmation instance used to customize the UI along with accept and reject actions. Properties
                of the Confirmation API used by the component are listed below.
            </p>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Default</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>message</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Message of the confirmation.</td>
                        </tr>
                        <tr>
                            <td>key</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Optional key to match the key of the confirm popup, necessary to use when component tree has multiple confirm popups.</td>
                        </tr>
                        <tr>
                            <td>icon</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Icon to display next to the message.</td>
                        </tr>
                        <tr>
                            <td>accept</td>
                            <td>Function</td>
                            <td>null</td>
                            <td>Callback to execute when action is confirmed.</td>
                        </tr>
                        <tr>
                            <td>reject</td>
                            <td>Function</td>
                            <td>null</td>
                            <td>Callback to execute when action is rejected.</td>
                        </tr>
                        <tr>
                            <td>acceptLabel</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Label of the accept button.</td>
                        </tr>
                        <tr>
                            <td>rejectLabel</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Label of the reject button.</td>
                        </tr>
                        <tr>
                            <td>acceptIcon</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Icon of the accept button.</td>
                        </tr>
                        <tr>
                            <td>rejectIcon</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Icon of the reject button.</td>
                        </tr>
                        <tr>
                            <td>acceptVisible</td>
                            <td>boolean</td>
                            <td>true</td>
                            <td>Visibility of the accept button.</td>
                        </tr>
                        <tr>
                            <td>rejectVisible</td>
                            <td>boolean</td>
                            <td>true</td>
                            <td>Visibility of the reject button.</td>
                        </tr>
                        <tr>
                            <td>acceptButtonStyleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the accept button.</td>
                        </tr>
                        <tr>
                            <td>rejectButtonStyleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the reject button.</td>
                        </tr>
                        <tr>
                            <td>defaultFocus</td>
                            <td>string</td>
                            <td>accept</td>
                            <td>Element to receive the focus when the popup gets visible, valid values are "accept", "reject", and "none".</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>ConfirmationService</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Parameters</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>confirm</td>
                            <td>confirm: Confirmation Object</td>
                            <td>Displays the overlay using the confirmation object options.</td>
                        </tr>
                        <tr>
                            <td>close</td>
                            <td>-</td>
                            <td>Hides the overlay without invoking accept or reject callbacks.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Animation Configuration</h5>
            <p>Transition of the open and hide animations can be customized using the <i>showTransitionOptions</i> and <i>hideTransitionOptions</i> properties,
                example below disables the animations altogether.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-confirmPopup [showTransitionOptions]="'0ms'" [hideTransitionOptions]="'0ms'"&gt;&lt;/p-confirmPopup&gt;
</app-code>

            <h5>Properties</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Default</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>key</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Optional key to match the key of confirm object, necessary to use when component tree has multiple confirm dialogs.</td>
                        </tr>
                        <tr>
                            <td>showTransitionOptions</td>
                            <td>string</td>
                            <td>.12s cubic-bezier(0, 0, 0.2, 1)</td>
                            <td>Transition options of the show animation.</td>
                        </tr>
                        <tr>
                            <td>hideTransitionOptions</td>
                            <td>string</td>
                            <td>.1s linear</td>
                            <td>Transition options of the hide animation.</td>
                        </tr>
                        <tr>
                            <td>autoZIndex</td>
                            <td>boolean</td>
                            <td>true</td>
                            <td>Whether to automatically manage layering.</td>
                        </tr>
                        <tr>
                            <td>baseZIndex</td>
                            <td>number</td>
                            <td>0</td>
                            <td>Base zIndex value to use in layering.</td>
                        </tr>
                        <tr>
                            <td>style</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the component.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the component.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Styling</h5>
            <p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>.</p>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Element</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>p-confirm-popup</td>
                            <td>Container element</td>
                        </tr>
                        <tr>
                            <td>p-confirm-popup-content</td>
                            <td>Content element.</td>
                        </tr>
                        <tr>
                            <td>p-confirm-popup-icon</td>
                            <td>Message icon.</td>
                        </tr>
                        <tr>
                            <td>p-confirm-popup-message</td>
                            <td>Message text.</td>
                        </tr>
                        <tr>
                            <td>p-confirm-popup-footer</td>
                            <td>Footer element for buttons.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Dependencies</h5>
            <p>ConfirmationService</p>
        </p-tabPanel>

        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/confirmpopup" class="btn-viewsource" target="_blank">
                <span>View on GitHub</span>
            </a>
            <a href="https://stackblitz.com/edit/primeng-confirmpopup-demo" class="btn-viewsource" style="margin-left: .5em;" target="_blank">
                <span>Edit in StackBlitz</span>
            </a>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-toast&gt;&lt;/p-toast&gt;

&lt;p-confirmPopup&gt;&lt;/p-confirmPopup&gt;

&lt;button (click)="confirm($event)" pButton icon="pi pi-check" label="Confirm"&gt;&lt;/button&gt;
</app-code>

<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
import &#123;Component&#125; from '@angular/core';
import &#123;ConfirmationService, MessageService&#125; from 'primeng/api';

@Component(&#123;
    templateUrl: './confirmpopupdemo.html',
    providers: [ConfirmationService, MessageService]
&#125;)
export class ConfirmPopupDemo &#123;

    constructor(private confirmationService: ConfirmationService) &#123;&#125;

    confirm(event: Event) &#123;
        this.confirmationService.confirm(&#123;
            target: event.target,
            message: 'Are you sure that you want to proceed?',
            icon: 'pi pi-exclamation-triangle',
            accept: () =&gt; &#123;
                this.messageService.add(&#123;severity:'info', summary:'Confirmed', detail:'You have accepted'&#125;);
            &#125;,
            reject: () =&gt; &#123;
                this.messageService.add(&#123;severity:'error', summary:'Rejected', detail:'You have rejected'&#125;);
            &#125;
        &#125;);
    &#125;
&#125;
</app-code>
        </p-tabPanel>
        <p-tabPanel header="StackBlitz">
            <ng-template pTemplate="content">
                <iframe src="https://stackblitz.com/edit/primeng-confirmpopup-demo?embed=1" style="width: 100%; height: 768px; border: none;"></iframe>
            </ng-template>
        </p-tabPanel>
    </p-tabView>
</div>
